<?php
// 应用公共文件
//把数组拆分几个
function sliceArray($arr, $Enum=4, $Anum=2) {
    $newArr = array();
    for($i=0;$i<$Anum;$i++) {
        $newArr[] =array_slice($arr, $i * $Enum, $Enum);
    }
    return $newArr;
}

//登录
function http_request($url, $ret='', $file='') {
    if(!empty($file)) {
        $ret['media'] = new CURLFile($file);
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_USERAGENT, 'MSIE001');
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

    if($ret) {
        curl_setopt($ch, CURLOPT_POST,1);
        curl_setopt($ch, CURLOPT_POSTFIELDS,$ret);

    }
    $data = curl_exec($ch);
    if(curl_errno($ch)>0) {
        echo curl_error($ch);
        $data = '';
    }
    curl_close($ch);
    return $data;

}